package com.ruoyi.business.service.impl;

import com.ruoyi.business.domain.WmsTray;
import com.ruoyi.business.mapper.WmsTrayMapper;
import com.ruoyi.business.service.IWmsTrayService;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 托盘管理Service业务层处理
 * 
 * @author yunlong
 * @date 2023-12-19
 */
@Service
public class WmsTrayServiceImpl implements IWmsTrayService
{
    @Autowired
    private WmsTrayMapper wmsTrayMapper;

    /**
     * 查询托盘管理
     * 
     * @param id 托盘管理ID
     * @return 托盘管理
     */
    @Override
    public WmsTray selectWmsTrayById(Long id)
    {
        return wmsTrayMapper.selectWmsTrayById(id);
    }

    @Override
    public WmsTray selectWmsTrayBySn(String sn) {
        WmsTray wmsTray = new WmsTray();
        wmsTray.setSn(sn);
        List<WmsTray> list = wmsTrayMapper.selectWmsTrayList(wmsTray);
        if(list.isEmpty()){
            return null;
        }else{
            return list.get(0);
        }
    }

    /**
     * 查询托盘管理列表
     * 
     * @param wmsTray 托盘管理
     * @return 托盘管理
     */
    @Override
    public List<WmsTray> selectWmsTrayList(WmsTray wmsTray)
    {
        return wmsTrayMapper.selectWmsTrayList(wmsTray);
    }

    /**
     * 新增托盘管理
     * 
     * @param wmsTray 托盘管理
     * @return 结果
     */
    @Override
    public int insertWmsTray(WmsTray wmsTray)
    {
        wmsTray.setCreateTime(DateUtils.getNowDate());
        return wmsTrayMapper.insertWmsTray(wmsTray);
    }

    /**
     * 修改托盘管理
     * 
     * @param wmsTray 托盘管理
     * @return 结果
     */
    @Override
    public int updateWmsTray(WmsTray wmsTray)
    {
        wmsTray.setUpdateTime(DateUtils.getNowDate());
        return wmsTrayMapper.updateWmsTray(wmsTray);
    }

    /**
     * 删除托盘管理对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWmsTrayByIds(String ids)
    {
        return wmsTrayMapper.deleteWmsTrayByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除托盘管理信息
     * 
     * @param id 托盘管理ID
     * @return 结果
     */
    @Override
    public int deleteWmsTrayById(Long id)
    {
        return wmsTrayMapper.deleteWmsTrayById(id);
    }
}
